<?php

    global $mikron;

    $with_ajax = isset($_GET['ajax']);
    if($with_ajax)
    {
        ob_clean();
    }

    try
    {
        ShowData($with_ajax);
    }
    catch(Exception $ex)
    {
        
    }

    if($with_ajax)
    {
        $mikron->Page->EndBody(false);
        exit;
    }
    else{$mikron->Page->EndBody();}

    function ShowData()
    {
        global $mikron;
        if(!isset($_GET['id']))
        {
            throw new Exception('Карточка не найдена.');
        }
        $id = (int)$_GET['id'];
        $card = new T_PERSON($id);
        $cardinfo = $card->DisplayName();
        $cardid = $card->id;
        $carddt = MikronDateTime::BeautifulDate(strtotime($card->dt->value));
        $polis = $card->omsseries->value." ".$card->omsnumber->value;
        $birthday = MikronDateTime::BeautifulDate(strtotime($card->birthday->value)).' г.';
        
        ?><h2>Карточка №<?php echo $cardid; ?></h2><?php
        $frm = new html_form('cardinfo', 'get', '/remoterecord/cardinfo.php', null, 1);
        $table = new html_table(2, 'table1', null, 4);
            $table->newcol("Фамилия:");
            $table->newcol(); $frm->addInput(1, 'lastname', null, 40, null, false, $card->lastname->value);
            $table->newcol("Имя:");
            $table->newcol(); $frm->addInput(1, 'firstname', null, 40, null, false, $card->firstname->value);
            $table->newcol("Отчество:");
            $table->newcol(); $frm->addInput(1, 'fathername', null, 40, null, false, $card->fathername->value);
            $table->newcol("Дата рождения:");
            $table->newcol(); $frm->addInput(1, 'birthday', null, 20, null, false, $birthday);
            $table->newcol('Полис:');
            $table->newcol(); $frm->addInput(1, 'polis', null, 20, null, false, $polis);
            /*$table->newcol('&nbsp;');
            $table->newcol();*/
        $table->end();
        $frm->end();
        ?><button id="exclosebutton2" onclick="$('div#cardinfo').fadeOut();">Закрыть</button><?php
    }

?>